package cn.edu.scau.dropship.ServiceImpl;

import cn.edu.scau.dropship.entity.Goods;
import cn.edu.scau.dropship.entity.Order_goods;
import cn.edu.scau.dropship.entity.Order_goodsExample;
import cn.edu.scau.dropship.entity.Order_goodsKey;
import cn.edu.scau.dropship.mapper.Order_goodsMapper;
import cn.edu.scau.dropship.service.OrderGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderGoodsServiceImpl implements OrderGoodsService {
    @Autowired
    private Order_goodsMapper order_goodsMapper;

    @Override
    public long countByExample(Order_goodsExample example) {
        return order_goodsMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(Order_goodsExample example) {
        return order_goodsMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Order_goodsKey key) {
        return order_goodsMapper.deleteByPrimaryKey(key);
    }

    @Override
    public int insert(Order_goods record) {
        return order_goodsMapper.insert(record);
    }

    @Override
    public int insertSelective(Order_goods record) {
        return order_goodsMapper.insertSelective(record);
    }

    @Override
    public List<Order_goods> selectByExample(Order_goodsExample example) {
        return order_goodsMapper.selectByExample(example);
    }

    @Override
    public Order_goods selectByPrimaryKey(Order_goodsKey key) {
        return null;
    }

    @Override
    public int updateByExampleSelective(Order_goods record, Order_goodsExample example) {
        return order_goodsMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(Order_goods record, Order_goodsExample example) {
        return order_goodsMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(Order_goods record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Order_goods record) {
        return 0;
    }

    @Override
    public List<Order_goods> selectByOid(Integer oid) {
        Order_goodsExample order_goodsExample=new Order_goodsExample();
        Order_goodsExample.Criteria criteria=order_goodsExample.createCriteria();
        criteria.andOrderIdEqualTo(oid);
        List<Order_goods> list=order_goodsMapper.selectByExample(order_goodsExample);
        return list;
    }

    public void delete(Order_goodsKey record)
    {
        order_goodsMapper.deleteByPrimaryKey(record);
    }

    public List<Goods> selectGoodByOrderID(Integer id){
        return order_goodsMapper.selectGoodByOrderID(id);
    }



    public  Order_goods selectByPrimaryKey(Integer goodsID , Integer orderID){
        Order_goodsKey order_goodsKey=new Order_goodsKey(goodsID,orderID);
        return order_goodsMapper.selectByPrimaryKey(order_goodsKey);
    }

    public Order_goods select(Order_goodsKey key){
        return order_goodsMapper.selectByPrimaryKey(key);
    }
}
